<include file="../Address/header" />
<body>
<div class="wraper">
	<div class="load">
		<img class="load-bee" src="/assets/base/repair/images/load-bee.png"/>
	</div>
    <div class="top">
        <p><a href="javascript:history.go(-1)" class="iconfont icon-zuo fl-left"></a>
			<if condition="$picked neq 1">
				地址管理
				<else/>
				联系方式管理
			</if>
		</p>
    </div>
    <div class="list-box">
    	<volist name="data" id="vo">
        <div class="list clearfix <if condition='$vo.default eq 1'>check</if>">
            <div class="left fl-left"  data-id="{BEESCRM:$vo['address_id']}" data-type="{BEESCRM:$picked}">
                <p>{BEESCRM:$vo['real_name']} {BEESCRM:$vo['mobile']}</p>
				<p class="sub">{BEESCRM:$vo['address_detail']} </p>
            </div>
            <div class="right fl-left">
                <a href="javascript:void(0)"class="iconfont icon-del-round shanchu fl-right" data-id="{BEESCRM:$vo['address_id']}" ></a>
                <a href="/base/storeZT/addAddress/store_id/{BEESCRM:$storeId}/address_id/{BEESCRM:$vo.address_id}/picked/{BEESCRM:$picked}" class="iconfont icon-jzd_xiugaishuxing bianji fl-right"></a>
            </div>
        </div>
        </volist>
    </div>
    <div class="marginb-50"></div>
    <div class="btn-box">
        <a href="{BEESCRM::U('base/storeZT/addAddress',array('picked'=>$picked,'store_id'=>$storeId))}" class="btn big">
			<if condition="$picked neq 1">
				新增地址
				<else/>
				新增联系方式
			</if>
		</a>
    </div>
</div>

<include file="../Address/commonJS" />
<script>
$(document).ready(function(){
	$('.list-box').on('click','.list',function(){
		$(this).addClass('check').siblings().removeClass('check');
	});

	$('.left').on('click',function(){
		var address_id = $(this).data('id');
		var type = $(this).data('type');
		if(address_id){
			$.ajax({
				type:'post',
				dataType:'json',
				data:{'address_id':address_id,'type':type},
				url:"{BEESCRM::U('base/storeZT/addressDefault',array('store_id'=>$storeId))}",
				success:function(data){
					if(data.status == 'S'){
						location.href =data.url;
					}else{
						$.alert('error',data.message);
					}
				},
				error:function(){
					$.alert('error','通讯错误');
				}
			});
		}
	});


	//删除显示confirm框
	$(document).on('click','.icon-del-round',function(){
		var address_id=$(this).data('id');
		var msg = '确认删除该条地址';
		$.confirm(msg, drop);
		function drop() {
			delLight(address_id)
		}
	});

	//确认删除
	function delLight(address_id){
		if(address_id == ''){
			$.alert('error','参数错误');
		}else{
			$.ajax({
				type : 'post',
				dataType : 'json',
				data : {'address_id':address_id,'cut_off':1},
				url : "{BEESCRM::U('base/storeZT/delAddress',array('store_id'=>$storeId))}",
				success : function(data) {
					if (data.status == 'S') {
						$.alert('success',data.message);
						setTimeout( "window.location.reload()", 2000);
					} else {
						$.alert('error',data.message);
					}
				},
				error : function(data) {
					$.alert('error','参数错误');
				}
			});
		}
	}
});
</script>
</body>

</html>
